<?php
error_reporting(E_WARNING);
include_once '../includes/metodos.php';
connectSql();
checkUser();

$query = mysql_query("SELECT * FROM tb_usuario WHERE id=".$_SESSION['id']);
$row_cliente = mysql_fetch_array($query);
$perfil = $row_cliente['perfil'];
include_once '../header.php';
?>
<body> 
<!-- Start: page-top-outer -->
<div id="page-top-outer">    
	<?php include_once '../menu.php';?>

<div id="page-heading"><h1>Clientes</h1></div>


<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
	<th rowspan="3" class="sized"><img src="<?php echo EXTERNAL_ROOT_PORTAL;?>/css/images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
	<th class="topleft"></th>
	<td id="tbl-border-top">&nbsp;</td>
	<th class="topright"></th>
	<th rowspan="3" class="sized"><img src="<?php echo EXTERNAL_ROOT_PORTAL;?>/css/images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
	<td id="tbl-border-left"></td>
	<td>
	<!--  start content-table-inner -->
	<div id="content-table-inner">
	
				<div class="clear"></div>
				
				<table border="0" width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<input class="button" type="button" onclick="location.href='<?php EXTERNAL_ROOT_PORTAL;?>/css/cliente/new.php';" value="Adicionar">
				</tr>
				</table>
				<br/>				
				<table width="100%" cellspacing="0" cellpadding="0" border="0" id="product-table">
				<tbody><tr>
					<th class="table-header-repeat" width="150px"><a href="">Cliente</a></th>
					<th class="table-header-repeat" width="100px"><a href="">Contatos</a></th>
					<th class="table-header-repeat" width="50px"><a href="">A&ccedil;&atilde;o</a></th>
				</tr>
				<?php 
				$query = mysql_query("SELECT * FROM tb_cliente ORDER BY nome ASC");
				if($perfil=='1'){
					while($row = mysql_fetch_array($query)){
						echo '<tr>';
							echo '<td>'.utf8_encode($row['nome']).'</td>';
							echo '<td>'.$row['telefone'].' / '.$row['celular'].'</td>';
							echo '<td>
									<form action="edit.php" method="post">
										<input type="hidden" name="id" value="'.$row['id'].'"/>
										<select name="cmd">
											<option value="">Editar</option>
											<option value="del">Deletar</option>
										</select>
										<input class="button" type="submit" value="Executar"/>
									</form>
									</td></tr>';
					}
				}else{
					while($row = mysql_fetch_array($query)){
						echo '<tr>';
							echo '<td>'.utf8_encode($row['nome']).'</td>';
							echo '<td>'.$row['telefone'].' / '.$row['celular'].'</td>';
							echo '<td><form action="edit.php" method="post"><input type="hidden" name="id" value="'.$row['id'].'"/><input class="button" type="submit" value="Editar"/></form></td></tr>';
					}
				}
				?>
				</tbody></table>
 
<div class="clear"></div>
 
</div>
<!--  end content-table-inner  -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
	<th class="sized bottomleft"></th>
	<td id="tbl-border-bottom">&nbsp;</td>
	<th class="sized bottomright"></th>
</tr>
</table>

<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer -->

 

<div class="clear">&nbsp;</div>
    
<!-- start footer -->         
<div id="footer">
	<!--  start footer-left -->
	<div id="footer-left">
	Admin Skin &copy; Copyright Internet Dreams Ltd. <a href="">www.netdreams.co.uk</a>. All rights reserved.</div>
	<!--  end footer-left -->
	<div class="clear">&nbsp;</div>
</div>
<!-- end footer -->
 
</body>
</html>